tipc: fix a possible memleak in tipc_buf_append
authorXin Long <lucien.xin@gmail.com>
Tue, 30 Apr 2024 14:03:38 +0000 (10:03 -0400)
committerSalvatore Bonaccorso <carnil@debian.org>
Fri, 3 May 2024 12:36:41 +0000 (14:36 +0200)
commitb98c5d3bd1214ca973096826cb89892e0f65346a
tree475f419b08fce8e12a583c1b901a160706ae2266
parent611708a480a6229fcabc3ff551b2548d3e1c9fd8
tipc: fix a possible memleak in tipc_buf_append

Origin: https://git.kernel.org/linus/97bf6f81b29a8efaf5d0983251a7450e5794370d

__skb_linearize() doesn't free the skb when it fails, so move
'*buf = NULL' after __skb_linearize(), so that the skb can be
freed on the err path.

Fixes: b7df21cf1b79 ("tipc: skb_linearize the head skb when reassembling msgs")
Reported-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Tung Nguyen <tung.q.nguyen@dektech.com.au>
Link: https://lore.kernel.org/r/90710748c29a1521efac4f75ea01b3b7e61414cf.1714485818.git.lucien.xin@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name tipc-fix-a-possible-memleak-in-tipc_buf_append.patch
net/tipc/msg.c